﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Urbania.Utilities;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Urbania.Components
{
    public class TitleAnimation : Microsoft.Xna.Framework.DrawableGameComponent
    {
        private GUI.LuaVM lua;
        private SpriteBatch spriteBatch;
        private Animation titleAnim;

        public TitleAnimation(Game game, ref GUI.LuaVM lua)
            : base(game)
        {
            this.lua = lua;
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            titleAnim = new Animation();
            Loader.LoadTex("Tiles\\Title");
            titleAnim.FrameWidth = 96;
            titleAnim.FrameHeight = 109;
            titleAnim.FrameRate = 2;
            titleAnim.RepeatFrameIndex = 0;
            titleAnim.FrameIndex = 0;
            titleAnim.SpriteSheet = Utilities.Loader.GetTex("Title");
            titleAnim.IsRunning = true;

            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);


            base.LoadContent();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            Utilities.MouseWrap.Update();
            titleAnim.Update(gameTime);

            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();

            spriteBatch.Draw(titleAnim, new Vector2(0, 0), Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}
